The present invention relates to interfacing of application programs with operating system device driver components and more particularly to method and system for exposing API functions of device drivers to application programs.
Device drivers provide access to third parities desiring to extend operating system capabilities. These device drivers enable the operating system to be used with a wide variety of hardware, because the user can install a set of device drivers that reflects the installed hardware of her particular system. Typically, device drivers run in privileged state because they must access hardware directly. Applications are typically blocked from directly calling the device drivers because application programs do not run in privilege state. Further, applications typically do not execute in the same address context as the device drivers.
Systems known in the art provide methods for applications to access device driver capabilities. One method for accessing device driver functions is to provide a general purpose access mechanism through an application programming interface (API). The API comprises a set of callable functions which enables a user application to communicate with a device driver by sending messages. These messages contain specific data for the device driver. The API mechanism also allows applications to receive data from the device driver. Many applications communicate with device drivers by some form of this Message based API.
However, these methods add an extra layer of complexity because they are intended to be general purpose. Greater speed and interoperabilities could be realized in cases where it would be desirable to invoke the driver directly.
The present invention provides techniques for improved interfacing of application programs with operating system device drivers. More particularly, the present invention provides a surrogate function for applications to invoke device driver capabilities.
According to an embodiment of the present invention, a method for interfacing of application programs with operating system device drivers is provided. The method includes a variety of steps such as assigning an arbitrary message number to each of a plurality of functions from a device driver. Steps of providing a wrapper program for the application and a wrapper program for the device driver are also part of the method. The method then includes a step of providing a xe2x80x98surrogatexe2x80x99 function for the application to call. A step of extracting all parameters passed into the function is performed when an application program invokes the surrogate function is performed by the wrapper program for the application. A step of storing the parameters into a data packet along with a corresponding message number can also be part of the method. Next, a method step of sending the data packet to the wrapper program for the device driver is performed. In a subsequent step, the device driver wrapper program determines which function the application is invoking by the message number. A step of unpacking the parameters from the data packet is part of the method. The method then calls the corresponding function in the device driver. In many embodiments, data returned from the function is passed back through an analogous mechanism. The combination of these steps can provide an interface between the application and the device driver.
In another aspect of the present invention, a computer program product for interfacing an application program to a device driver can comprise code for performing a variety of steps, including code for assigning an unique identifier to each of a plurality of functions performable by the device driver. Code for providing a wrapper program for the application, that has at least one surrogate function for the application to invoke. The surrogate function corresponds to one of the plurality of functions performable by the device driver can also be part of the product. The product can also include code for providing a wrapper program for the device driver and code for extracting at least one parameter passed from the application responsive to an invocation of one of the plurality of functions of the device driver by the application program through the surrogate function. Further, code for storing the at least one parameter in a data packet along with a unique corresponding message number and code for sending the data packet to the wrapper program for the device driver are included. Embodiments can also include code for determining in the wrapper program for the device driver a selected function being invoked by the application program using the unique corresponding message number, as well as code for retrieving the at least one parameter from the data packet. Additionally, code for invoking the one of the plurality of functions of the device driver corresponding to the message number is also part of the product. Finally, a computer readable storage medium is included for holding the code.
Numerous benefits are achieved by way of the present invention over conventional techniques. In some embodiments, the present invention is more computationally efficient than conventional techniques. The present invention can provide a way for the user to access device driver functions without resorting to computationally expensive API access techniques. Some embodiments according to the invention are more robust than known techniques. These and other benefits are described throughout the present specification and more particularly below.
A further understanding of the nature and advantages of the inventions herein may be realized by reference to the remaining portions of the specification and the attached drawings.